package com.yuexun.beilunpatient.ui.satisfaction.presenter.impl;

import com.yuexun.beilunpatient.base.BaseEntity;
import com.yuexun.beilunpatient.ui.satisfaction.bean.SatisfactionTypeBean;
import com.yuexun.beilunpatient.ui.satisfaction.model.ISatisfactionModel;
import com.yuexun.beilunpatient.ui.satisfaction.presenter.ISatisfactionTypeListPresenter;
import com.yuexun.beilunpatient.ui.satisfaction.ui.view.ISatisfactionTypeListView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2018/8/28.
 */
public class SatisfactionTypeListPresenter implements ISatisfactionTypeListPresenter {

    private ISatisfactionModel model;
    private ISatisfactionTypeListView view;

    public SatisfactionTypeListPresenter(ISatisfactionModel model, ISatisfactionTypeListView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void getSatisfactionTypeList(Map<String, String> praise) {
        model.getSatisfactionTypeList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<SatisfactionTypeBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(BaseEntity<SatisfactionTypeBean> bean) {
                        view.getSatisfactionTypeList(bean);
                    }
                });
    }
}
